//+------------------------------------------------------------------+
//|                                                      pattern.mq4 |
//|                                         Dimitri Rudel 28.10.2013 |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Dimitri Rudel 28.10.2013"
#property link      ""



int p_getSignal(){
   int result = 0;
   result = getStar();
   //if(!result){
     // result = getMidStar();
   //}
   
   
   return (result);
}



double getRodSize(int shift){
   return (MathAbs(High[shift] - Low[shift])); 
}

double getBodySize(int shift){
   return (MathAbs(Close[shift] - Open[shift])); 
}

int getStar(){
   int result = 0;
   if(getBodySize(3) > 0){
      if(getBodySize(2) / getBodySize(3) <= 0.33){
         if(getDirection(3) == 0 && Close[1] < Low[3]){
            result = 1;
         }else if(getDirection(3) == 1 && Close[1] > High[3]){
            result = 1;
         }
      }
   } 
   return (result);  
}

int getMidStar(){
   int result = 0;
   if(getBodySize(4) > 0){
      if((getBodySize(2) / getBodySize(4) <= 0.33) && (getBodySize(3) / getBodySize(4) <= 0.33)){
         if(getDirection(4) == 0 && Close[1] < Low[4]){
            result = 1;
         }else if(getDirection(4) == 1 && Close[1] > High[4]){
            result = -1;
         }
      }
   } 
   return (result);  
}







int getDirection(int shift){
   int result = -1;
   if(Close[shift] > Open[shift]){
      result = 0;
   }else if(Close[shift] < Open[shift]){
      result = 1;
   }
   return (result);
}

bool p_isBullish(int shift){
   return (getDirection(shift) == 0);
}

bool p_isBearish(int shift){
   return (getDirection(shift) == 1);
}


